<?php
/**
 * 阅读公告
 * Created by PhpStorm.
 * User: devforma
 * Date: 16-6-6
 */

class ReadAnnounce implements iController {

    public function output($queryArgs) {
        global $uddb;

        if (validateUser($queryArgs) !== 1 || empty($queryArgs['announce_id'])) {
            return genOutput(1000);
        }

        $exists = $uddb->getVar('SELECT `id` FROM `history_user_announce` WHERE `user_id`=:uid AND `announce_id`=:aid', [':uid' => $queryArgs['user_id'], ':aid' => $queryArgs['announce_id']]);
        if (!$exists)
            $uddb->insert('history_user_announce', ['announce_id' => $queryArgs['announce_id'], 'user_id' => $queryArgs['user_id']]);

        return genOutput(1);
    }
}